<%@ page import="com.graduation.lastproject.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: cyy
  Date: 2020/3/27
  Time: 8:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    /*int userIntegral=((User)request.getSession().getAttribute("userInfo")).getIntegral();*/
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<c:set var="ctx" value="<%=basePath%>"  />
<%--<c:set var="userIntegral" value="<%=userIntegral%>" />--%>
<html>
<head>
    <title>商品兑换</title>
    <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/toastr/toastr.min.css">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/bootstrap/js/bootstrap.min.js"></script>
    <script src="/static/js/home/mycommodity.js"></script>
    <script src="/static/toastr/toastr.min.js"></script>
    <style type="text/css">
        img{
            width: 250px;
            height: 250px;
        }
    </style>
    <script>
        var ctx='${ctx}'
    </script>
</head>
<body>
    <div>
         <c:forEach items="${pageInfo.list}" var="commodity">
             <div class="col-md-3">
                 <img src="/img/picImg?url=${commodity.commodity_pic}">
                 <p style="max-width:250px;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;color:#872962" onmousemove="removeClassType(this)">介绍:${commodity.commodity_des}</p>
                 <h4>
                     积分:<span style="margin-right: 30px;color: #DC143C">${commodity.commodity_integral}</span>
                     库存:<span style="color: #DC143C"> ${commodity.reserve}</span>
                 </h4>
                 <c:choose>
                     <c:when test="${commodity.reserve >0}">
                         <button type="button" class="btn btn-primary"  data-toggle="modal" data-target="#exchangeModal" onclick="exchange('${commodity.id}','${commodity.commodity_pic}',${userIntegral},${commodity.commodity_integral})">兑换</button>
                     </c:when>
                     <c:otherwise>
                         <button type="button" class="btn btn-primary disabled">缺货</button>
                     </c:otherwise>
                 </c:choose>
             </div>
         </c:forEach>
        <div class="col-md-12">
            <p>
                当前 <span>${pageInfo.pageNum}</span> 页,总 <span>${pageInfo.pages}</span> 页,共 <span>${pageInfo.total}</span> 条记录
            </p>
            <ul class="pagination">
                <li><a href="${ctx}homeHigh/myintegral">第一页</a> </li>
                <c:choose>
                    <c:when test="${pageInfo.hasPreviousPage == 'true'}">
                        <li><a href="${ctx}homeHigh/myintegral?pageNum=${pageInfo.prePage}")>上一页</a></li>
                    </c:when>
                    <c:otherwise>
                        <li><a href="${ctx}homeHigh/myintegral?pageNum=1">上一页</a></li>
                    </c:otherwise>
                </c:choose>
                <c:choose>
                    <c:when test="${pageInfo.hasNextPage == 'true'}">
                        <li><a href="${ctx}homeHigh/myintegral?pageNum=${pageInfo.nextPage}">下一页</a></li>
                    </c:when>
                    <c:otherwise>
                        <li><a href="${ctx}homeHigh/myintegral?pageNum=${pageInfo.pages}">下一页</a></li>
                    </c:otherwise>
                </c:choose>
                <li><a href="${ctx}homeHigh/myintegral?pageNum=${pageInfo.pages}">最后一页</a></li>
            </ul>
        </div>
    </div>

    <%--兑换模态框--%>
    <div class="modal fade" id="exchangeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="reviewlLabel">兑换框</h4>
                </div>
                <div class="modal-body" >
                    <input type="hidden" name="commodity_id" id="commodity_id"/>
                    <input type="hidden" name="commodity_pic" id="commodity_pic"/>
                    <input type="hidden" name="commodity_integral" id="commodity_integral"/>
                    <input type="text" placeholder="请填写完整收货地址" required id="commodity_address" class="form-control" autocomplete="off">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="exchangeActive">兑换</button>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
